package edu.sctu.alex.June.day20150623;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

/**
 * Created by alex on 2015/6/23.
 */
public class PostInfo {

    public String getWebInfo(String path) {

        StringBuilder json = new StringBuilder();

        try {
            URL url = new URL(path);

            URLConnection connection = url.openConnection();

            InputStream is = connection.getInputStream();

            BufferedReader reader = new BufferedReader(new InputStreamReader(is));

            String line = "";

            while ((line = reader.readLine()) != null) {

                json.append(line);
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        System.out.println(json.toString());

        return json.toString();
    }
}